<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<style>
.table {table-layout:fixed;}
.table tbody tr td{
      overflow: hidden; 
      text-overflow:ellipsis;  
      white-space: nowrap; 
 }
</style>
<script type="text/javascript">

    var tt = 0;
    $(function(){
    	 battcn.ns('battcn.admin.menu${OP.menu}');
    	 $('#admin_menu${OP.menu}_datagrid').bootstrapTable({ 
             url:rootPath + '${MENU.channel}/query',
             height: '100%',
             sortName: 'releaseDate',
             sortOrder: 'desc',
             striped: true,
             pagination: true,
             pageSize: 10,
             pageList: [10, 25, 50, 100, 200],
             search: false,
             sidePagination:'server',
             idField: 'id',
             uniqueId: 'id',
             responseHandler: responseHandler,
             queryParams: queryParams,
             minimumCountColumns: 2,
             clickToSelect: true,
             columns: [ {
                 field: 'title',
                 title: '电影名字',
                 align: 'center',
                 valign: 'middle',
                 width:'20',
                 sortable: true
             },{
                 field: 'type',
                 title: '类型',
                 align: 'center',
                 valign: 'middle',
                 width: '10',
                 sortable: true
             },
             {
                 field: 'grade',
                 title: '评分',
                 align: 'center',
                 valign: 'middle',
                 width: '10',
                 sortable: true
             },
             {
                 field: 'releasedate',
                 title: '上映时间',
                 align: 'center',
                 valign: 'middle',
                 width: '30',
                 sortable: true,
                 formatter:function(value,row,index){
                	 if(value!=null&&value!=undefined){
                		 return new Date(value).pattern("yyyy-MM-dd ");
                	 }else{
                		 return "";
                	 }
                	 
                	}
             },{
            	  field: 'content',
                  title: '简介',
                 align: 'center',
                 valign: 'middle',
                 width: '60',
                 sortable: true
             },{
                 field: 'caozuo',
                 title: '操作',
                 align: 'center',
                 valign: 'middle',
                 width: '20',
                 formatter: function(val,row)
                 {
                	 return '<a href="javascript:showMovieDetail('+row.id+');" ><i class="fa fa-save text-navy" data-toggle="tooltip" title="123131"></i></a>';
                 },
                 sortable: true
             } ],  
             onLoadSuccess: function (data) {
             },
             onLoadError: function (status) {
             }              
	     });
	});
    


function analyzeMovie(id){
	battcn.showWindow({
		title:'电影年份统计数据',
		href:rootPath + '/dataAnalysis/movie/showMovieAnnee',
		width:'50%',
		height:'80%',
		type:2,
		cancelhandler:function(){
			battcn.closeWindow();
		}
});
}
    
function showMovieAnnee(){
	battcn.showWindow({
		title:'电影年份统计数据',
		href:rootPath + '/dataAnalysis/movie/showMovieAnnee',
		width:'50%',
		height:'80%',
		type:2,
		cancelhandler:function(){
			battcn.closeWindow();
		}
});
}


function search(){
	 $('#admin_menu${OP.menu}_datagrid').bootstrapTable('refresh');
}
//展示
battcn.admin.menu${OP.menu}.show = function(){
	showMovieAnnee();
};


//展示电影详情
showMovieDetail = function(id){
	battcn.showWindow({
		title:'展示电影详情',
		href:rootPath + '/dataAnalysis/movie/showMovieDetail?id='+id,
		width:'50%',
		height:'80%',
		type:2,
		cancelhandler:function(){
			battcn.closeWindow();
		}
	});
	
};
//电影爬虫
battcn.admin.menu${OP.menu}.crawler = function(){
	
	battcn.ajaxJson({url:rootPath + '/Crawler/getMovies'},function(){
		 $('#admin_menu${OP.menu}_datagrid').bootstrapTable('refresh');
	});
	
};

//停止爬虫
battcn.admin.menu${OP.menu}.spiderStop = function(){
	battcn.ajaxJson({url:rootPath + '/Crawler/spiderStop'},function(){
		 $('#admin_menu${OP.menu}_datagrid').bootstrapTable('refresh');
	});
	
};

//电影爬虫补充
battcn.admin.menu${OP.menu}.add = function(){
	
	layer.open({
		title:'电影爬虫补充',
		shadeClose : false,
		moveOut : true,
		shade : 0.5,
		maxmin:true,
		area : ['30%','30%'],
		content : $("#crawlerFormId").html(),
		btn : ['提交','取消'],
		yes :function(){
			
			battcn.ajaxJson({url:rootPath + '/Crawler/CrawlerByUrl',data:{url:$(".layui-layer-content #crawlerUrl").val()}},function(result){
				 $('#admin_menu${OP.menu}_datagrid').bootstrapTable('refresh');
    		});
			battcn.closeWindow();
		},
		chanel : function(){
			battcn.closeWindow();
		}

	});
	
};

//传递的参数
function queryParams(params) {
	var pageSize = params.limit;
	var sort = params.sort;
	var offset = params.offset;
	var order = params.order;
	var pageNum = offset / pageSize + 1;
	return {
		pageSize : pageSize,
		pageNum : pageNum,
		sort : sort,
		order : order,
		name:$("#moviename").val()
	}
}
</script>

<div class="ibox float-e-margins model-body" id="crawlerFormId" >
	<div class="ibox-content">
		<input type="text" class="form-control" id="crawlerUrl" />
		<span class="help-block m-b-none"><i class="fa fa-info-circle"></i>如发现电影有电影未添加请将电影网址输进去(比如https://www.80s.tw/movie/22259)</a></span>
	</div>
</div>

<div class="wrapper wrapper-content animated fadeInRight">
	<div class="ibox float-e-margins">
	
		<div class="ibox-content">
		<div class="panel panel-default">
					<div class="panel-body">
						<form id="formSearch" class="form-horizontal">
							<div class="form-group" style="margin-top: 15px">
								<label class="control-label col-sm-1" for="txt_search_departmentname">名称</label>
								<div class="col-sm-3">
									<input type="text" class="form-control" id="moviename">
								</div>
								<div class="col-sm-4" style="text-align: left;">
									<button type="button"  onclick = "search();"
										class="btn btn-primary">查询</button>
								</div>
							</div>
						</form>
					</div>
		</div>
		
		<!-- 权限上标 新增编辑等 -->
			<%@ include file="/WEB-INF/views/common/toolbar.jsp"%>
			<div class="table-responsive">
				<table id="admin_menu${OP.menu}_datagrid" data-toolbar="#toolbar"
					data-show-refresh="true" data-show-toggle="true"
					data-show-columns="true" data-show-footer="false"
					data-mobile-responsive="true">
				</table>
			</div>
		</div>
	</div>
</div>
